<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        window.onload = function(){
            //为id=bt1的按钮绑定事件调用函数
            document.getElementById('bt1').onclick = function(){
                //获取id为li1的节点
                var li1 = document.getElementById('li1');
                alert(li1.innerHTML);
            }
            //为id=bt2的按钮绑定事件调用函数
            document.getElementById('bt2').onclick = function(){
                //获取所有li
                var lis = document.getElementsByTagName('li');
                for(var i = 0;i<lis.length;i++){
                    alert(lis[i].innerHTML)
                }
            }
            //为id=bt3的按钮绑定事件调用函数
            document.getElementById('bt3').onclick = function(){
                //获取name=gender的节点
                var genders = document.getElementsByName('gender')
                for(var i = 0;i<genders.length;i++){
                    alert(genders[i].value)
                }
                
            }
        }
    </script>
    <style>
        .d1{
            display: inline-block;
            margin-left: 100px;
            margin-top: 100px;
            background-color: lightblue;
        }
        .d1>ol>li{
            display: inline-block;
            background-color: antiquewhite;
        }
        .d2{
            display:inline-block;
            position:absolute;
            margin-left: 50px;
            margin-top: 100px;
            
        }
        .d2>button{
            display: block;
        }
    </style>
</head>
<body>
    <div class="d1">
        <p>端游列表</p>
        <ol>
            <li id="li1">英雄联盟</li>
            <li>QQ飞车</li>
            <li>魔兽争霸</li>
            <li>地下城</li>
        </ol>
        <p>手游列表</p>
        <ol>
            <li>原神</li>
            <li>王者荣耀</li>
            <li>qq飞车手游</li>
        </ol>
        <span>性别：</span>
        男<input type="radio" name="gender" value="男">
        女<input type="radio" name="gender" value="女">
    </div>
    <div class="d2">
        <button id="bt1">获取id为li1的节点 </button>
        <button id="bt2">获取所有li</button>
        <button id="bt3">获取name=gender所有节点</button>
    </div>
</body>
</html>